package com.tc.zigbee.entity.device.ha;

import com.tc.gateway.device.ha.TemperatureSensor;
import com.tc.gateway.device.listener.SimpleSensorListener;
import com.tc.util.DataUtil;
import com.tc.zigbee.entity.Endpoint;
import com.tc.zigbee.entity.device.ZigbeeDevice;
import com.tc.zigbee.mt.ZigbeeManager;
import com.tc.zigbee.zcl.ZclConstants;
import com.tc.zigbee.zcl.command.DataValue;

public class ZigbeeTemperatureSensor extends ZigbeeDevice<SimpleSensorListener> implements TemperatureSensor{

	public ZigbeeTemperatureSensor(Endpoint endpoint,ZigbeeManager m) {
		super(endpoint,m);
		// TODO Auto-generated constructor stub
	}

	public void action() {
		

	}

	public int getTemperature() {
		DataValue dv = this.endpoint.getAttribute(ZclConstants.ZCL_CLUSTER_ID_MS_PRESSURE_MEASUREMENT, (short)0x0000);
		if(dv == null)
			return 0;
		return DataUtil.shortValue(dv.value);
	}

	@Override
	public double getMax() {
		// TODO Auto-generated method stub
		return 100;
	}

	@Override
	public double getMin() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getUnit() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public double getValue() {
		// TODO Auto-generated method stub
		return getTemperature();
	}

	
}
